<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<button onclick="getData()">点我测试</button>
		返回数据如下:
		<p id="res"></p>
	</body>
	<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
	<script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js"></script>
	<script src="../static/js/mui.js"></script>
	<script type="text/javascript">
		var res;
		function getData(){
			$.ajax({
				type: "post",
				url: "http://127.0.0.1/test",

				// contentType: "application/json;charset=UTF-8",
				// data: {
				//
				// 	id : 5
				// },
				dataType: "json",
				// 下面这句话允许跨域的cookie访问
				xhrFields: {
					withCredentials: true
				},
				// 允许跨域
				crossDomain: true,
				success: function(result,status,xhr) {
					console.log(result)
					res = result
					$("#res").text(res)

				},
				error: function() {
					alert("连接服务器失败...")
				},


			});
		}


	</script>

	<script>

		
			mui.ajax('http://127.0.0.1/test',{
						
							dataType:'json',//服务器返回json格式数据
							type:'post',//HTTP请求类型
							timeout:10000,//超时时间设置为10秒；
							//headers:{'Content-Type':'application/json'},	              
							success:function(data){
								//服务器返回响应，根据响应结果，分析是否登录成功；
								console.log(JSON.stringify(data));
							
									
							},
								
						
							error:function(xhr,type,errorThrown){
								//异常处理；	
								alert("服务器连接异常");
							}
						});
		
	</script>

<script>
	console.log(1)
</script>
</html>